
class RequestBuilder {
    private url: string | null = null
    private data: object | null = null
    private method: 'get' | 'post' | null = null

    private constructor() { }

    static builder(): RequestBuilder {
        return new RequestBuilder()
    }

    setUrl(url: string): this {
        this.url = url
        return this
    }

    setMethod(method: 'get' | 'post'): this {
        this.method = method
        return this
    }

    setObject(data: object): this {
        this.data = data
        return this
    }

    send() {
        console.info(`url:${this.url} --- method:${this.method}`)
    }
}

function run() {
    RequestBuilder
        .builder()
        .setUrl("http://www.baidu.com")
        .setMethod("get")
        .send()
}

run()